widget: Fix gtk_widget_get_surface_allocation
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 06:04:22 +0000 (02:04 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 06:04:22 +0000 (02:04 -0400)
As the name implies, this should be surface-relative
coordinates, so it needs to take the surface transform
into account.

gtk/gtkwidget.c

index a537530b80d9f0fb78a861d111c5eef52233650a..d3c9e7232fdac9422c5b960bd4f60fb8f5af87db 100644 (file)
@@ -3447,6 +3447,7 @@ gtk_widget_get_surface_allocation (GtkWidget     *widget,
 {
   GtkWidget *parent;
   graphene_rect_t bounds;
+  int nx, ny;
 
   /* Don't consider the parent == widget case here. */
   parent = _gtk_widget_get_parent (widget);
@@ -3454,12 +3455,13 @@ gtk_widget_get_surface_allocation (GtkWidget     *widget,
     parent = _gtk_widget_get_parent (parent);
 
   g_assert (GTK_IS_WINDOW (parent) || GTK_IS_POPOVER (parent));
+  gtk_native_get_surface_transform (GTK_NATIVE (parent), &nx, &ny);
 
   if (gtk_widget_compute_bounds (widget, parent, &bounds))
     {
       *allocation = (GtkAllocation){
-        floorf (bounds.origin.x),
-        floorf (bounds.origin.y),
+        floorf (bounds.origin.x) + nx,
+        floorf (bounds.origin.y) + ny,
         ceilf (bounds.size.width),
         ceilf (bounds.size.height)
       };